// doc: https://github.com/Selection-Translator/translation.js/
const { youdao, baidu, google } = require('translation.js')

module.exports = {
    load() {
        // 当 package 被正确加载的时候执行
    },

    unload() {
        // 当 package 被正确卸载的时候执行
    },

    messages: {
        'open'() {
            // open entry panel registered in package.json
            Editor.Panel.open('yd-translater');
        },
        'translation'(e, content) {
            youdao.translate(content)
                .then(res => {
                    let resultArr = res.result
                    // Editor.log(resultArr)
                    Editor.Ipc.sendToPanel('yd-translater', 'set-result', resultArr)
                })
        }
    },
}